const comGetStorage = function(key) {
	return new Promise((resolve, reject) => {
		uni.getStorage({
			key: key,
			success: ((res) => {
				console.log(res)
				resolve(res.data)
			}),
			fail: ((res) => {
				resolve(null)
			}),
			complete: ((res) => {
				// console.log(res)
			})
		});
	})
}
const comSetStorage = function(key, data, fn) {
	return new Promise((resolve, reject) => {
		uni.setStorage({
			key: key,
			data: data,
			success: ((res) => {
				fn();
			}),
			fail: ((res) => {
				reject(null)
			}),
			complete: ((res) => {
				// console.log(res)
			})
		});
	})
}
const comGetLocation = function() {
	return new Promise((resolve, reject) => {
		uni.getLocation({
			type: 'wgs84',
			success: function(res) {
				reject(res)
			},
			fail: function() {
				reject(null)
			}
		});
	})
}
const comgetSystemInfo = function() {
	return new Promise((resolve, reject) => {
		uni.getSystemInfo({
		    success: function (res) {
		        console.log(res.model);
		        console.log(res.pixelRatio);
		        console.log(res.windowWidth);
		        console.log(res.windowHeight);
		        console.log(res.language);
		        console.log(res.version);
		        console.log(res.platform);
				reject(res)
		    },
			fail:function(){
				reject(null)
			}
		});
	})
}

export default {
	comGetStorage,
	comSetStorage,
	comGetLocation,
	comgetSystemInfo
}
